import Vue from 'vue'

import Cookies from 'js-cookie'
import './assets/wykj-icon/iconfont.css'
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import Moment from 'moment'
import Element from 'element-ui'
// import VueAMap from 'vue-amap'
/* VueAMap.initAMapApiLoader({
  key: '9f261d3e6c0a724850a5d6a30094db93',
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor', 'Geocoder'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
})*/
import './styles/element-variables.scss'
// import enLang from 'element-ui/lib/locale/lang/en'// 如果使用中文语言包请默认支持，无需额外引入，请删除该依赖

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import * as filters from './filters' // global filters
Vue.prototype.$moment = Moment// 赋值使用
import md5 from 'js-md5'
Vue.prototype.$md5 = md5
Moment.locale('zh-cn')// 需要汉化
// Vue.use(VueAMap)
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
  // locale: enLang // 如果使用中文，无需设置，请删除
})

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

// 正则表达式验证是否空
Vue.prototype.$isNull = function(v) {
  if (v === '') return true
  var regu = '^[ ]+$'
  var re = new RegExp(regu)
  return re.test(v)
}

// 正则表达式验证手机号
Vue.prototype.$telText = (rule, value, callback) => {
  var mobile = /^1(3|4|5|6|7|8|9)\d{9}$/
  if (mobile.test(value)) {
    callback()
  } else {
    return callback(new Error('请输入正确的手机号'))
  }
}

// 正则表达式验证邮箱
Vue.prototype.$emailText = function(v) {
  var email = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/
  if (email.test(v)) {
    return true
  } else {
    return false
  }
}

// 正则表达式验证密码
Vue.prototype.$passwordText = function(v) {
  var password = /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{8,16}$/ // 密码正则 密码包含 数字,英文,字符中的两种以上，长度8-16位
  if (password.test(v)) {
    return true
  } else {
    return false
  }
}

Vue.prototype.$uploadUrl = process.env.VUE_APP_BASE_API + '/sys/common/upload'

// 创建区块数据id
Vue.prototype.$createBlockDataId = function(blockId, id) {
  return this.$md5(blockId + '-' + id)
}

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
